Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gadget hdf: reduce size 1 header arrays to scalar #4414

Merged

Conversation

chrishavlin
Copy link
Contributor

This PR is one way to fix an issue reported on slack by Ben Oppenheimer: the CAMELS Astrid (Gadget-3, HDF) simulations have some hdf5 attributes saved as single element arrays but yt expects scalars, which leads to errors on dataset initialization.

The fix here simply reduces length 1 arrays to scalar values in the base gadget class.

Note that this particular flavor of HDF5 Gadget output does not have a dedicated frontend in yt. Assuming all the yt tests pass (Ben confirmed it does indeed allow loading of data and outputs from analysis seem correct), the fix here is simple enough that it seemed worth submitting even though a new frontend is a better long term solution. I also don't have a good datafile for testing, so just mocked up a header with nested arrays in the new test that I added.

@chrishavlin chrishavlin added enhancement Making something better code frontends Things related to specific frontends labels Apr 12, 2023
@chrishavlin
Copy link
Contributor Author

oops, look like I didn't properly exclude the new test from nose...

nose_ignores.txt Outdated Show resolved Hide resolved
chrishavlin and others added 2 commits June 14, 2023 10:14
Co-authored-by: Clément Robert <cr52@protonmail.com>
neutrinoceros
neutrinoceros previously approved these changes Jun 17, 2023
Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than a stylistic nit I should have caught earlier, LGTM !

yt/frontends/gadget/tests/test_gadget_pytest.py Outdated Show resolved Hide resolved
jzuhone
jzuhone previously approved these changes Jun 20, 2023
Co-authored-by: Clément Robert <cr52@protonmail.com>
@chrishavlin chrishavlin dismissed stale reviews from jzuhone and neutrinoceros via 10b8a8b June 20, 2023 15:04
@neutrinoceros neutrinoceros enabled auto-merge June 20, 2023 15:50
@neutrinoceros
Copy link
Member

let's try backporting this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code frontends Things related to specific frontends enhancement Making something better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants